package com.boomkeeper.archive.filter;

import java.io.File;
import java.io.FileFilter;

import org.apache.commons.lang3.StringUtils;

import com.boomkeeper.core.constant.Constant;
import com.google.common.io.Files;

public class FileNameFilter implements FileFilter {
	
	private String searchName;
	
	public FileNameFilter(String searchName) {
		this.searchName = searchName;
	}

	@Override
	public boolean accept(File file) {
		return file.isFile() && 
				Constant.ARCHIVE_FILE_TYPES.contains(Files.getFileExtension(file.getName().toLowerCase())) && 
				StringUtils.contains(file.getName(), this.searchName);
	}
	
	public static void main(String[] args) {
		System.out.println(StringUtils.contains("LTE-Scheme-20180711-3093535-xuyexin.docx", "LTE-Scheme"));
	}
}
